returns X and Y coordinate given i and j position in grid(i,j)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | X | |||
real(kind=float), | intent(in) | :: | Y | |||
type(grid_real), | intent(in) | :: | grid | |||
integer, | intent(out) | :: | i | |||
integer, | intent(out) | :: | j | |||
logical, | intent(out), | optional | :: | check |
return false if i and j are outside grid definition |
SUBROUTINE GetIJfloat & ! (X, Y, grid, i, j, check) IMPLICIT NONE !Arguments with intent(in): REAL (KIND = float), INTENT(IN) :: X,Y TYPE (grid_real), INTENT(IN) :: grid !Arguments with intent(out): INTEGER, INTENT(OUT) :: i, j LOGICAL, OPTIONAL, INTENT(OUT) :: check !!return false if i and j are outside grid definition !------------end of declaration------------------------------------------------ j = INT ( (X - grid % xllcorner) / grid %cellsize ) + 1 i = INT ( (grid % yllcorner + grid % idim * grid % cellsize - y) & / grid%cellsize ) + 1 IF (PRESENT (check)) THEN IF (i < 1 .OR. i > grid % idim .OR. j < 1 .OR. j > grid % jdim ) THEN check = .FALSE. ELSE check = .TRUE. END IF END IF END SUBROUTINE GetIJfloat